<template>
	<view>
		<block v-for="(item, key) in style" :key="key">
			<TopBox v-if="item.sign=='topBox'" :float="item.float" :name="item.name" :type="item.type" :path="item.path"></TopBox>
			<UserBox v-if="item.sign=='userBox'" :pic="item.pic"></UserBox>
			<SwiperBox v-if="item.sign=='swiperBox'" :mode="item.mode" :height="item.height" :datas="item.datas"></SwiperBox>
			<ButtonBox v-if="item.sign=='buttonBox'" :row="item.row" :margin="item.margin" :datas="item.datas"></ButtonBox>
			<ImgBox v-if="item.sign=='imgBox'" :datas="item.datas" :height="item.height"></ImgBox>
			<TrademarkSearch v-if="item.sign=='trademarkSearch'" :margin="item.margin" :name="item.name"></TrademarkSearch>
			<BannerBox v-if="item.sign=='bannerBox'" :pic="item.pic" :name="item.name" :desc="item.desc"></BannerBox>
			<ListBox v-if="item.sign=='listBox'" :margin="item.margin" :url="item.url" :path="item.path" :pic="item.pic" :type="item.type" :filter="item.filter" :datas="item.datas"></ListBox>
			<TabBar v-if="item.sign=='tabBar'" :datas="item.datas"></TabBar>
			<ParserBox v-if="item.sign=='parserBox'" :datas="item.datas"></ParserBox>
			<InfoBox v-if="item.sign=='infoBox'" :url="item.url" :field="item.field" :prefix="item.prefix" :extend="item.extend" :parserBox="item.parserBox" :swiperBox="item.swiperBox" :magicBlock="item.magicBlock" :postForm="item.postForm"></InfoBox>
			<MagicBlock v-if="item.sign=='magicBlock'" :datas="item.datas" :font="item.font" :pic="item.pic" :event="item.event" :config="item.config" :float="item.float"></MagicBlock>
			<PostForm v-if="item.sign=='postForm'" :form_id="item.form_id" :button="item.button" :url="item.url" :datas="item.datas"></PostForm>
		</block>
	</view>
</template>

<script>
import UserBox from '@/components/userBox'
import TabBar from '@/components/tabBar'
import TopBox from '@/components/topBox'
import ButtonBox from '@/components/buttonBox'
import ImgBox from '@/components/imgBox'
import TrademarkSearch from '@/components/trademarkSearch'
import SwiperBox from '@/components/swiperBox'
import BannerBox from '@/components/bannerBox'
import ListBox from '@/components/listBox'
import ParserBox from '@/components/parserBox'
import InfoBox from '@/components/infoBox'
import MagicBlock from '@/components/magicBlock'
import PostForm from '@/components/postForm'
export default {
	components: {
		UserBox,
		TabBar,
		TopBox,
		ButtonBox,
		ImgBox,
		TrademarkSearch,
		SwiperBox,
		BannerBox,
		ListBox,
		ParserBox,
		InfoBox,
		MagicBlock,
		PostForm
	},
	props: {
		refresh: Number
	},
	data() {
		return {
			path : '',
			style : {}
		}
	},
	watch:{
		'refresh'(){
			this.loadData('refresh')
		}
	},
	mounted() {
		//#ifdef MP
		uni.showShareMenu()
		uni.hideTabBar()
		//#endif
		let pages = getCurrentPages()
		let currentPage = pages[pages.length - 1]
		this.path = '/'+currentPage.route
		if(!getApp().globalData.config){
			getApp().globalData.callBack = callback => {
				getApp().globalData.config = callback
				this.loadData()
			}
		}else{
			this.loadData()
		}
	},
	methods: {
		async loadData(action) {
			if(action == 'refresh'){
				let token = uni.getStorageSync('token')
				uni.clearStorageSync()
				uni.setStorageSync('token',token)
			}
			if(this.path){
				this.style = {}
				this.style = await this.$api('GET','style',{path:this.path})
			}
		}
	}
}
</script>

<style lang='scss'>
	
</style>